package cn.wolfcode.trip.app.controller;

import cn.wolfcode.trip.base.domain.CommentSpeak;
import cn.wolfcode.trip.base.service.ICommentSpeakService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("commentSpeak")
public class CommmentSpeakController {
    @Autowired
    ICommentSpeakService commentSpeakService;
    //根据id获取评论
    @RequestMapping( method = RequestMethod.GET)
    public List<CommentSpeak> listAll() {
        return commentSpeakService.listAll();
    }
    @RequestMapping( value="/{id}",method = RequestMethod.GET)
    public CommentSpeak getById(@PathVariable Long id ) {
        return commentSpeakService.getById(id);
    }


    @RequestMapping(method = RequestMethod.POST)
    public String  insert(CommentSpeak commentSpeak) {

        try {
            commentSpeakService.save(commentSpeak);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "";
    }

}
